<?php 
namespace Home\Controller;
use Home\Controller;

class PersonController extends BaseController {
	public function index(){
		
		
		$uid=$_SESSION['uid'];
		$data=M('user')->find($uid);
		$this->assign('data',$data);
		$this->display();
	}
	public function upload(){
		$this->display();
	}
    public function webup(){
               $config = array(
		   				'mimes'         =>  array(), //允许上传的文件MiMe类型
		   				'maxSize'       =>  0, //上传的文件大小限制 (0-不做限制)
		   				'exts'          =>  array('jpg', 'gif', 'png', 'jpeg'), //允许上传的文件后缀
		   				'autoSub'       =>  true, //自动子目录保存文件
		   				'subName'       =>  array('date', 'Y-m-d'), //子目录创建方式，[0]-函数名，[1]-参数，多个参数使用数组
		   				'rootPath'      =>  './Uploads/Person/', //保存根路径
		   				'savePath'      =>  '',//保存路径
		   			  
		   		);
		   		$upload = new \Think\Upload($config);// 实例化上传类
		   		$info   =   $upload->upload();
		   		if(!$info) { 
		   			$this->error($upload->getError());// 上传错误提示错误信息 
		   		}else{// 上传成功
		   			/*
		   			 * 分离缩略图和轮播图
		   			 */
		   			foreach ($info as $va){
		   				
		   				if ($va['key']=="suoluetu"){
		   					$suoluetu.="Public/Uploads/luxian/".$va['savepath'].$va['savename']."||";
		   				}else {
		   					$lunbotu.="/workspace/webroot/Uploads/Person/".$va['savepath'].$va['savename'];
		   				}
		   			}
					$uid=$_SESSION['uid'];
					    $res['uid']=$uid;
					   $data['photo']=$lunbotu;
					M('user')->where($res)->save($data);
					$arr['su']=1;
					$this-ajaxReturn($arr);
					
                     

		   		}
    }

  public function updatep(){
		$this->display();
	}
	 public function doupdatep(){
		 $pwd=I('request.pwd');
		 $pwd=md5($pwd);
		 $uid=$_SESSION['uid'];
		$result=M('user')->where(array('uid'=>$uid))->save(array('pwd'=>$pwd));
		if($result){
   
    $this->success('修改成功', 'index');
} else {
   
    $this->error('新增失败','index');
}
	}

 public function checkpwd(){
        $pwd=I('get.ypwd');
        $uname=$_SESSION['username'];
        $ypwd=md5($pwd);
        $res=M('user')->where(array('uname'=>$uname,'pwd'=>"$ypwd"))->find();
        $re=array();
        if($res){
            $re['msg']='密码正确!';
            $re['status']=true;     
        }else{
            $re['msg']='密码不正确,请重新输入!';
            $re['status']=false;    
        }
        $this->ajaxReturn($re);

    }

	 public function money(){
		 $uid=$_SESSION['uid'];
		 $moneys=I('REQUEST.money');
		 $money=$moneys+10;
        $res=M('user')->where(array('uid'=>$uid))->save(array('money'=>$money));
        $re=array();
        if($res){
            $re['money']=$money;
            $re['status']=true;     
        }else{
            $re['money']=$moneys;
            $re['status']=false;    
        }
        $this->ajaxReturn($re);

    }
	 public function addmoney(){
		 
       $this->display();
	   
    }

	

}














 ?>